<script>
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    window.location = '/mobile'; //可以换成http地址
}
</script>
<!-- 头部部分 -->
<style>
    .main-active {
        background: linear-gradient(0deg, rgba(215, 0, 15, 1), rgba(236, 67, 67, 1));
        /* 一下为兼容ie9渐变 */
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eb3f40', endColorstr='#db0e1a', GradientType=0);
        box-shadow: 0px 0px 5px 0px rgba(110, 1, 9, 0.6);
        font-size: 16px;
        font-family: SourceHanSansSC;
        font-weight: 400;
        color: white;
        position: relative;
        z-index: 88;
    }
</style>

<header>
    <div class="headers">
        <div class="header-top">
            <div class="header-top-right">
                {{if $get.category != 'list_search'}}
                <div class="input-serch">
                    <input class="search" placeholder="搜索...">
                    <img class="serch-go" src="{{$static_path}}/static/images/search.png" alt="">
                </div>
                {{/if}}
                {{if $member_info['loginname'] == ''}}
                <a class="login" href="/page_login">登录</a>
                <a class="register" href="/page_register">注册</a>
                {{else}}
                <div class="oklogin">
                    <span class="txt">欢迎 
                        <a href="/page_user-homepage">
                            {{if $member_info['nickname'] != ''}}
                                {{$member_info['nickname']}}
                            {{else}}
                                {{$member_info['loginname']}}
                            {{/if}}
                        </a>
                    </span>
                    <a class="login" id="h-logout" href="javascript:;">退出</a>
                </div>
                {{/if}}
            </div>
        </div>
    </div>
    <!-- header中间的选项切换部分 -->
    <div class="header-content">
        <div class="headers-content">
            <div class="logo">
                <img src="{{$static_path}}/static/images/header/logo.png" alt="">
            </div>
            <ul class="list-nav">
                <li><a href="/" {{if $get.category == ''}}class="main-active"{{/if}}>首页</a> <span></span></li>
                {{navigation parentid="0"}}
                    {{foreach $list as $k => $v}}
                        <li><a href="{{$v['url']}}" {{if $get.category|in_array:$v['allchildurl']}}class="main-active"{{/if}}>{{$v['name']}}</a><span></span> </li>
                    {{/foreach}}
                {{/navigation}}
            </ul>
        </div>

    </div>
</header>

<script>

    // $(document).ready(function () {
    //     $(".list-nav li>a").each(function (v, i) {
    //         $this = $(this);

    //         //    添加选中效果判断当前的字段是否有这个字段url
    //         if(v == 0){
    //             if( window.location.pathname == $this.attr('href') ){
    //                 $(this).addClass("main-active");
    //             } 
    //         }else{
    //             if( parseInt(window.location.href.indexOf($this.attr('href'))) > 0 ){
    //                 $(this).addClass("main-active");
    //             }
    //         }


    //         // 详情页面的indexof判断

    //         if ($this[0].href.indexOf("_dh") == String(window.location.href.indexOf("_dh") - 2)) {
    //             if (v == 1) {
    //                 $(this).addClass("main-active");
    //             }
    //         }
    //         if ($this[0].href.indexOf("_college") == String(window.location.href.indexOf("_college") - 2)) {
    //             if (v == 2) {
    //                 $(this).addClass("main-active");
    //             }
    //         }
    //         if ($this[0].href.indexOf("_Investor") == String(window.location.href.indexOf("_Investor") - 2)) {
    //             if (v == 3) {
    //                 $(this).addClass("main-active");
    //             }
    //         }
    //         if ($this[0].href.indexOf("_curriculum") == String(window.location.href.indexOf("_curriculum") - 2)) {
    //             if (v == 4) {
    //                 $(this).addClass("main-active");
    //             }
    //         }
    //         if ($this[0].href.indexOf("_exhibition") == String(window.location.href.indexOf("_exhibition") - 2)) {
    //             if (v == 6) {
    //                 $(this).addClass("main-active");
    //             }
    //         }

    //         if ($this[0].href.indexOf("_tj") == String(window.location.href.indexOf("_tj") - 2)) {
    //             if (v == 7) {
    //                 $(this).addClass("main-active");
    //             }
    //         }


    //     });

    // });


    //   切割cookie
    var cookieTxts = document.cookie.split(';')[0].split('=')[1]
    //   var cookieTxt = document.cookie.
    var htmltxt
    if ($('.wz-span').children("a:last-child")[0] != undefined) {
        htmltxt = $('.wz-span').children("a:last-child")[0].innerText
        //   设置cookie
        document.cookie = "txt=" + htmltxt;
    }


    if ($('.wz-spans').children("a:last-child")[0] != undefined) {
        var detailTxt = $('.wz-spans').children("a:last-child")
        detailTxt[0].innerText = cookieTxts

    }




    // 搜索跳转
    $('.serch-go').click(function () {
        var key = $('.search').val();
        if(key){
            window.location.href = 'list_search?key=' + key
        }
    })
    window.onunload = function(){
        $('.search').val('')
    }





</script>
<script type="text/javascript">
    $('#h-logout').click(function(){
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: "/member/logout",
            success: function(data){
                if(data.code == 0){
                    window.location.href = '/'
                }else{
                    alert('退出失敗')
                }
            },
            error: function(){
          
            }
        })
    })
</script>